const { Role } = require('board-game');

const extend = require('extend');

class CountingRole extends Role {
    constructor(server, room, player, team, index) {
        super(server, room, player, team, index);
        this.wrong = false;
        this.right = false;
        this.count = false;
    }
    doCount() { //报数
        this.board.doCount(this);
    }
    doPass() {  //过
        this.board.doPass(this);
    }
    confirmWrong() {
        this.board.confirmWrong();
    }
    clearStatus() {
        this.count = false;
        this.wrong = false;
        this.right = false;
    }
    doWrong(type, count) {
        this.count = count;
        this.wrong = type;
        this.right = false;
    }
    doRight(count) {
        this.count = count;
        this.wrong = false;
        this.right = true;
    }
    get data() {
        return extend(true, super.data, this.counter);
    }
    get counter() {
        return {
            wrong: this.wrong,
            right: this.right,
            count: this.count
        }
    }
}

module.exports = CountingRole;
